// 获取路径
var pathName = window.document.location.pathname;
// 截取，得到项目名称
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);

// tab切换
$('.stat-page-item').click(function() {
	$(this).addClass('active').siblings().removeClass('active');
    $(this).parents('.stat-panel-heading').siblings('.stat-panel-body').find('.stat-panel-body-item').eq($(this).index()).fadeIn(200).siblings().fadeOut(200);
    //饼图
    var myChart3 = echarts.init(document.getElementById('panel-left-sex-stat'));
//    option3 = {
//        tooltip : {
//            trigger: 'item',
//            formatter: "{a} <br/>{b} : {c} ({d}%)"
//        },
//        legend: {
//            orient: 'vertical',
//            left: 'left',
//            data: ['男','女']
//        },
//        series : [
//            {
//                name: '访问来源',
//                type: 'pie',
//                radius : '55%',
//                center: ['50%', '60%'],
//                data:[
//                    {value:1, name:'男'},
//                    {value:1, name:'女'}
//                ],
//                itemStyle: {
//                    emphasis: {
//                        shadowBlur: 10,
//                        shadowOffsetX: 0,
//                        shadowColor: 'rgba(0, 0, 0, 0.5)'
//                    }
//                }
//            }
//        ]
//    };
//    myChart3.setOption(option3);
    
    $.get(projectName+"/statAction_userSexCount",function(data){
    	myChart3.setOption({
            tooltip : {
                trigger: 'item',
                formatter: "{a} <br/>{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                left: 'left',
                data: data[name]
            },
            series: [{
                name: '性别统计',
                type: 'pie',
                radius : '55%',
                center: ['50%', '60%'],
                data:data
            }]
        })
    },"json")

    //折线图
    var myChart4 = echarts.init(document.getElementById('panel-right-age-stat'));
    option4 = {
        xAxis: {
            type: 'category',
            data: ['0-20', '21-30', '31-40', '41-50', '51以上', '未知年龄']
        },
        yAxis: {
            type: 'value'
        },
        series: [{
            data: [120, 140, 160, 1330, 20, 100],
            type: 'line'
        }]
    };
    myChart4.setOption(option4);

    // 树状图
    var myChart5 = echarts.init(document.getElementById('panel-bottom-address-stat'));
    var option5 = {
        tooltip: {},
        legend: {
            data:['籍贯统计']
        },
        xAxis: {
            data: ["湖北","湖南","上海","广东","江西","浙江","湖北","湖南","上海","广东","江西","浙江","湖北","湖南","上海","广东","江西","浙江","湖北","湖南","上海","广东","江西","浙江"]
        },
        yAxis: {},
        series: [{
            name: '籍贯统计',
            type: 'bar',
            data: [5, 20, 36, 10, 10, 20,5, 20, 36, 10, 10, 20,5, 20, 36, 10, 10, 20,5, 20, 36, 10, 10, 20]
        }]
    };
    myChart5.setOption(option5);
})

/*=========评估统计=======*/

//饼图
var myChart = echarts.init(document.getElementById('panel-left-stat'));
// option = {
//     tooltip : {
//         trigger: 'item',
//         formatter: "{a} <br/>{b} : {c} ({d}%)"
//     },
//     legend: {
//         orient: 'vertical',
//         left: 'left',
//         data: ['批捕','不批捕']
//     },
//     series : [
//         {
//             name: '访问来源',
//             type: 'pie',
//             radius : '55%',
//             center: ['50%', '60%'],
//             data:[
//                 {value:1, name:'批捕'},
//                 {value:1, name:'不批捕'}
//             ],
//             itemStyle: {
//                 emphasis: {
//                     shadowBlur: 10,
//                     shadowOffsetX: 0,
//                     shadowColor: 'rgba(0, 0, 0, 0.5)'
//                 }
//             }
//         }
//     ]
// };
// myChart.setOption(option);
$.get(projectName+"/statAction_jiyaCount",function(data){
	myChart.setOption({
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: data[name]
        },
        series: [{
            name: '批捕情况统计',
            type: 'pie',
            radius : '55%',
            center: ['50%', '60%'],
            data:data
        }]
    })
},"json")

//环图
var myChart1 = echarts.init(document.getElementById('panel-right-stat'));
//option2 = {
//    tooltip: {
//        trigger: 'item',
//        formatter: "{a} <br/>{b}: {c} ({d}%)"
//    },
//    legend: {
//        orient: 'vertical',
//        x: 'left',
//        data:['初犯','偶犯','其它']
//    },
//    series: [
//        {
//            name:'访问来源',
//            type:'pie',
//            radius: ['50%', '70%'],
//            avoidLabelOverlap: false,
//            label: {
//                normal: {
//                    show: false,
//                    position: 'center'
//                },
//                emphasis: {
//                    show: false,
//                    textStyle: {
//                        fontSize: '30',
//                        fontWeight: 'bold'
//                    }
//                }
//            },
//            labelLine: {
//                normal: {
//                    show: false
//                }
//            },
//            data:[
//                {value:10, name:'初犯'},
//                {value:1, name:'偶犯'},
//                {value:2, name: '其它'}
//            ]
//        }
//    ]
//};
//myChart1.setOption(option2);

$.get(projectName+"/statAction_crimeTypeCount",function(data){
	myChart1.setOption({
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: data[name]
        },
        series: [{
            name: '初犯偶犯统计',
            type: 'pie',
            radius : '55%',
            center: ['50%', '60%'],
            data:data
        }]
    })
},"json")

// 树状图
var myChart2 = echarts.init(document.getElementById('panel-bottom-stat'));
//var option = {
//    tooltip: {},
//    legend: {
//        data:['案由评估统计']
//    },
//    xAxis: {
//        data: ["杀人","放火","抢劫","盗窃","车祸"]
//    },
//    yAxis: {},
//    series: [{
//        name: '案由评估统计',
//        type: 'bar',
//        data: [5, 20, 36, 10, 10]
//    }]
//};
//myChart2.setOption(option);
$.get(projectName+"/statAction_chargetypeCount",function(data){
	myChart2.setOption({
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            data: data[name]
        },
        series: [{
            name: '初犯偶犯统计',
            type: 'pie',
            radius : '55%',
            center: ['50%', '60%'],
            data:data
        }]
    })
},"json")


/*=========犯罪嫌疑人统计=======*/
if(!$('.stat-panel-body-two').hasClass('none')){
    alert(111);
}
